package cc.rengu.redp.base.config;

import com.alibaba.fastjson.serializer.ValueFilter;

/**
 * 解决：long超过16位之后JavaScript自动截断Long型造成精度丢失的问题
 * 方案：在此统一把超过16位的Long转换为String
 */
public class LongToStringSerializer implements ValueFilter {
    @Override
    public Object process(Object object, String name, Object value) {
        if (value != null && value instanceof Long) {
            if (((Long) value).longValue() >= 10000000000000000L) {
                value = value + "";
            }
        }
        return value;
    }
}
